package com.haizhi.crm.api.controller.favourite;

import com.haizhi.crm.biz.model.FavouriteQo;
import com.haizhi.crm.biz.service.FavouriteService;
import com.haizhi.crm.common.model.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * Desc:收藏／取消收藏；适用于客户、行内动态、行外事件、产品、拜访记录
 * Created by yangyijun on 2018/6/1.
 */
@Api(description = "[业务-收藏／取消收藏]-公用接口" )
@RestController
@RequestMapping("/favourite" )
public class FavouriteController {

    @Autowired
    private FavouriteService favouriteService;

    @ApiOperation(value = "公用-收藏／取消收藏", notes = "适用于客户、行内动态、行外事件、产品、拜访记录；保存信息到mysql库favourite表。 entityType：实体对应的表名" )
    @PostMapping("" )
    public Response favourite(@RequestBody @Valid FavouriteQo favouriteQo) {
        return favouriteService.favourite(favouriteQo);
    }

    @ApiOperation(value = "公用-获取收藏状态", notes = "status=已收藏返回true，未收藏返回false；适用于客户、行内动态、行外事件、产品、拜访记录；" )
    @GetMapping("/status" )
    public Response status(@RequestParam String entityType, @RequestParam String entityKey) {
        return favouriteService.status(entityType, entityKey);
    }
}
